﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FileBaseControl.cs" company="">
//   
// </copyright>
// <summary>
//   The file base control.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Libium.Controls
{
	using System.Drawing;
	using System.Drawing.Drawing2D;
	using System.Windows.Forms;
	using Libium.Views;

    /// <summary>
    /// The file base control.
    /// </summary>
    public partial class FileBaseControl : BindableUserControl, IFileView
    {
        #region Fields

        /// <summary>
        /// The _file path.
        /// </summary>
        private string _filePath;

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="FileBaseControl"/> class.
        /// </summary>
        public FileBaseControl()
        {
            InitializeComponent();
            //toolStrip.Renderer = new ToolStripSystemRenderer();
            TabStop = true;
        }

        #endregion

        #region Public Properties

        public bool AutoHideToolbox
        {
            get
            {
                return GetAutoHide(toolStrip);
            }
            set
            {
                SetAutoHide(toolStrip, value);
            }
        }

        /// <summary>
        /// Gets the clear command view.
        /// </summary>
        public object ClearCommandView
        {
            get
            {
                return ClearButton;
            }
        }

        /// <summary>
        /// Gets or sets the details text.
        /// </summary>
        public virtual string DetailsText
        {
            get
            {
                return "No file";
            }

            set
            {
            }
        }

        /// <summary>
        /// Gets or sets the file path.
        /// </summary>
        public string FilePath
        {
            get
            {
                return _filePath;
            }

            set
            {
                _filePath = value;
                OnFilePathChanged();
            }
        }

        /// <summary>
        /// Gets the load command view.
        /// </summary>
        public object BrowseCommandView
        {
            get
            {
                return BrowseButton;
            }
        }

        /// <summary>
        /// Gets the open command view.
        /// </summary>
        public object EditCommandView
        {
            get
            {
                return EditButton;
            }
        }

        /// <summary>
        /// Gets the refresh command view.
        /// </summary>
        public object RefreshCommandView
        {
            get
            {
                return RefreshButton;
            }
        }

        /// <summary>
        /// Gets the save as command view.
        /// </summary>
        public object SaveAsCommandView
        {
            get
            {
                return SaveAsButton;
            }
        }

        /// <summary>
        /// Gets or sets the text.
        /// </summary>
        public virtual string Text
        {
            get
            {
                return "No file";
            }

            set
            {
            }
        }

        #endregion

        #region Methods

        /// <summary>
        /// The on file path changed.
        /// </summary>
        protected virtual void OnFilePathChanged()
        {
        }

        /// <summary>
        /// The on paint.
        /// </summary>
        /// <param name="e">
        /// The e.
        /// </param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (Focused)
            {
                ControlPaint.DrawBorder(
                    e.Graphics, 
                    ClientRectangle, 
                    Color.Black, 
                    1, 
                    ButtonBorderStyle.Inset, 
                    Color.Black, 
                    1, 
                    ButtonBorderStyle.Inset, 
                    Color.Black, 
                    1, 
                    ButtonBorderStyle.Inset, 
                    Color.Black, 
                    1, 
                    ButtonBorderStyle.Inset);
            }
        }

        #endregion

		  private void FileBaseControl_Load(object sender, System.EventArgs e)
		  {
			  //Image img = new Bitmap(toolStrip.Width, toolStrip.Height);
			  //Brush br = new LinearGradientBrush(img.GetBounds(GraphicsUnit.Pixel), Color.White, Color.Gray, LinearGradientMode.Horizontal);
		  }
    }
}